<template>
  <view class="container">
    <view class="record-card">
      <view class="record-item">
        <text class="label">时间：</text>
        <text class="value">{{ recordData }}</text>
      </view>
      <view class="record-item">
        <text class="label">坐姿状态：</text>
        <text class="value">{{ msg }}</text>
      </view>
      <view class="record-item">
        <text class="label">记录时长：</text>
        <text class="value">{{ sittingTime }}</text>
      </view>
      <view class="record-item">
        <text class="label">异常坐姿时长：</text>
        <text class="value">{{ errorPostureTime }}</text>
      </view>
    </view>

    <view class="advice-card">
      <text class="advice-title">坐姿建议</text>
      <view class="advice-text">
        <view class="advice-point" v-for="(point, index) in randomAdvice" :key="index">{{ point }}</view>
      </view>
    </view>

    <view class="posture-gallery">
      <view class="posture-card">
        <text class="posture-title">良好坐姿示范 1</text>
        <image src="../../static/siting2.jpg" class="posture-image" />
      </view>
      <view class="posture-card">
        <text class="posture-title">良好坐姿示范 2</text>
        <image :src="`../../static/sitting2.png`" class="posture-image" />
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      recordData: '',
      msg: '',
      sittingTime: '',
      errorPostureTime: '',
      advices: [
        [
          '保持背部挺直，肩膀放松，可以有效减轻背部压力，预防脊椎问题。',
          '确保你的脚平放在地面上，膝盖呈90度角，这样可以减少腿部的压力。',
          '调整你的屏幕高度，使其与眼睛平行，避免低头或仰头看屏幕。'
        ],
        [
          '每隔一小时站起来活动几分钟，能促进血液循环，减少久坐带来的健康风险。',
          '可以做一些简单的伸展运动，放松肩膀和颈部的肌肉。',
          '使用符合人体工学的椅子和桌子，确保坐姿的舒适和正确。'
        ]
      ],
      randomAdvice: []
    };
  },
  onLoad(options) {
    console.log('Received options:', options);
    this.recordData = decodeURIComponent(options.recordData);
    this.msg = decodeURIComponent(options.msg);
    this.sittingTime = decodeURIComponent(options.sittingTime);
    this.errorPostureTime = decodeURIComponent(options.errorPostureTime);

    // 随机选择一组建议
    this.randomAdvice = this.advices[Math.floor(Math.random() * this.advices.length)];
  }
};
</script>

<style>
.container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background-color: #f0f4f8;
}

.record-card, .advice-card, .posture-card {
  background-color: #ffecb3;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
  width: 90%;
  max-width: 400px;
  margin-bottom: 20px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.record-item .label {
  font-weight: bold;
  color: #333;
}

.record-item .value {
  color: #666;
}

.record-item:last-child {
  margin-bottom: 0;
}

.advice-card .advice-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
}

.advice-card .advice-text {
  color: #666;
  line-height: 1.5;
}

.advice-point {
  margin-bottom: 8px;
}

.advice-point:last-child {
  margin-bottom: 0;
}

.posture-gallery {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 820px;
}

.posture-card {
  width: 45%;
  background-color: #fff3cd;
}

.posture-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
  text-align: center;
}

.posture-image {
  width: 100%;
	height: 340rpx;
  border-radius: 8px;
}
</style>
